<script>
import UButton from "../../../../uni_modules/uview-ui/components/u-button/u-button.vue";
import UIcon from "../../../../uni_modules/uview-ui/components/u-icon/u-icon.vue";
import BaseInfoCard from "../../../../components/business/base-info-card/index.vue";
import ClientProgrammeBtn from "../../../../components/business/client-programme-btn/index.vue";
import {STATION_STATUS} from "../enter/constant";
import {getPowerStationList} from "../../../../api/customer";

export default {
  name: "index",
  components: {ClientProgrammeBtn, UIcon, UButton, BaseInfoCard},
  data() {
    return {
      records: [],
      list: [],
      size: 10,
      page: 1,
      total: 0,
      STATION_STATUS,
    }
  },
  mounted() {
    // 获取信息列表
    this.getList();
  },
  methods: {
    async getList() {
      const { data: { records, size, total } } = await getPowerStationList({ pageNum: this.page, pageSize: this.size, queryType: 9});
      this.records = records;
      this.size = size;
      this.total = total;
    },
    toEdit() {
      uni.navigateTo({
        url: '/pages/index/home/enter/edit/index'
      })
    },
    scrolltolower() {
      if (this.size * this.page < this.total) {
        this.page++;
        this.getList();
      }
    },
  }
}
</script>

<template>
  <view class="enter">
    <!--条件筛选-->
    <!--列表-->
    <!--列表-->
    <u-list
        @scrolltolower="scrolltolower"
        v-if="records.length > 0"
    >
      <u-list-item
          v-for="item in records"
          :key="item.id"
      >
        <base-info-card
            v-for="item in records"
            :key="item.id"
            :object-code="item.powerStationCode"
            :roofType="item.roofType || '--'"
            :angle="item.angle"
            :azimuth="item.azimuth"
            :ownerName="item.tenantName"
            :ownerAddress="item.address || '暂无'"
            :status="item.status"
            :mobile="item.mobile"
            :data="item"
        >
          <template slot="footer">
            <view class="footer cell">
              <view class="cell-bd see">
                <client-programme-btn :psId="item.id" />
              </view>
              <view class="cell-hd btn">
                <u-button size="small" type="primary" @click="toEdit">验收</u-button>
              </view>
            </view>
          </template>
        </base-info-card>
      </u-list-item>
    </u-list>

    <view class="empty" v-if="records.length === 0">
      <u-empty
          mode="list"
          icon="http://cdn.uviewui.com/uview/empty/list.png"
      >
      </u-empty>
    </view>
  </view>
</template>

<style scoped lang="scss">
.enter{
  background: #f5f5f5;
  min-height: 100vh;
  padding: 10px;
}

.footer{
  //border-top: 1px dashed #eee;
  padding: 0px 0 10px 0;
  .see{
    font-size: 12px;
  }
  .btn{
    display: inline-block;
    padding: 0 5px;
  }
}
</style>
